import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/home/index.vue'
import KindView from '../views/kind/index.vue'
import CartView from '../views/cart/index.vue'
import UserView from '../views/user/index.vue'

import DetailView from '../views/detail/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      // redirect 配置路由重定向
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: HomeView
    },
    {
      path: '/kind',
      name: 'kind',
      component: KindView
    },
    {
      path: '/cart',
      name: 'cart',
      component: CartView
    },
    {
      path: '/user',
      name: 'user',
      component: UserView
    },
    {
      path: '/detail',
      name: 'detail',
      component: DetailView,
      meta: {
        hidden: true
      },
    },
    {
      path: '/login',
      name: 'login',
      // meta 是路由的元信息
      meta: {
        // 用来判断是否需要显示 footer
        hidden: true
      },
      component: () => import('../views/login/index.vue')
    }, {
      path: '/register',
      name: 'register',
      meta: {
        hidden: true
      },
      redirect: '/register/step1',
      component: () => import('../views/register/index.vue'),
      children: [
        {
          path: 'step1',
          name: 'step1',
          component: () => import('../views/register/step1.vue'),
        },
        {
          path: 'step2',
          name: 'step2',
          component: () => import('../views/register/step2.vue'),
        },
        {
          path: 'step3',
          name: 'step3',
          component: () => import('../views/register/step3.vue'),
        }
      ]
    }
  ]
})

export default router
